home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / private / _putc.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  3KB  |  123 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #ifdef UNIX
  4. #include <defs.h>
  5. #include <term.h>
  6. #endif
  7. #undef    PDC_putc
  8.  
  9. #ifdef PDCDEBUG
  10. char *rcsid__putc = "$Header: C:\CURSES\private\RCS\_putc.c 2.1 1993/06/18 20:23:03 MH Rel MH $";
  11. #endif
  12.  
  13.  
  14.  
  15.  
  16. /*man-start*********************************************************************
  17.  
  18.   PDC_putc()    - Output a character in the current attribute.
  19.  
  20.   PDCurses Description:
  21.      This is a private PDCurses routine.
  22.  
  23.      Outputs character 'chr' to screen in tty fashion. If a colour
  24.      mode is active, the character is written with colour 'colour'.
  25.  
  26.   PDCurses Return Value:
  27.      This function returns OK on success and ERR on error.
  28.  
  29.   PDCurses Errors:
  30.      No errors are defined for this function.
  31.  
  32.   Portability:
  33.      PDCurses    int PDC_putc( chtype character, chtype color );
  34.  
  35. **man-end**********************************************************************/
  36.  
  37. int    PDC_putc( chtype character, chtype color )
  38. {
  39. #ifdef    OS2
  40.     int curRow = PDC_get_cur_row ();
  41.     int curCol = PDC_get_cur_col ();
  42. #endif
  43.  
  44. #ifdef UNIX
  45. static chtype last_attribute=0;
  46. #ifdef CHTYPE_LONG
  47. static bool last_acs=FALSE;
  48. #endif
  49. static int curses_to_ansi[] = {0,4,2,6,1,5,3,7};
  50. short fore,back;
  51. #endif
  52.  
  53. #ifdef PDCDEBUG
  54.     if (trace_on) PDC_debug("PDC_putc() - called:char=%c attrib=0x%x color=0x%x\n",character & A_CHARTEXT,character & A_ATTRIBUTES,color);
  55. #endif
  56.  
  57. #ifdef    FLEXOS
  58.     retcode = s_write(0x00, 0x01L, (_far char *) &character, 1L, 0);
  59.     return( (retcode < 0L) ? ERR : OK );
  60. #endif
  61.  
  62. #ifdef    DOS
  63.     regs.h.ah = 0x09;    /* Avoid screen wrap.  Don't advance cursor. */
  64.     regs.h.al = (unsigned char) (character & A_CHARTEXT);
  65.     regs.h.bh = _cursvar.video_page;
  66.     regs.h.bl = (unsigned char) (color);
  67.     regs.x.cx = 1;
  68.     int86(0x10, ®s, ®s);
  69.     return( OK );
  70. #endif
  71.  
  72. #ifdef    OS2
  73.     VioWrtTTY ((PCH)&character, 1, 0);
  74.     VioWrtNAttr ((PBYTE)&color, 1, (USHORT)curRow, (USHORT)curCol, 0);
  75.     PDC_gotoxy (curRow, curCol);
  76.     return( OK );
  77. #endif
  78.  
  79. #ifdef UNIX
  80.     if (last_attribute != color)
  81.         {
  82.         if (exit_attribute_mode != NULL)
  83.             putp(exit_attribute_mode);
  84.         last_attribute = color;
  85.         if ((color & A_COLOR) && has_colors())
  86.             {
  87.             pair_content(PAIR_NUMBER(color),&fore,&back);
  88.             putp(tparm(set_foreground,curses_to_ansi[fore]));
  89.             putp(tparm(set_background,curses_to_ansi[back]));
  90.             }
  91.         if (color & A_BOLD)
  92.             if (enter_bold_mode != NULL)
  93.                 putp(enter_bold_mode);
  94.         if (color & A_BLINK)
  95.             if (enter_blink_mode != NULL)
  96.                 putp(enter_blink_mode);
  97.         if (color & A_REVERSE)
  98.             if (enter_reverse_mode != NULL)
  99.                 putp(enter_reverse_mode);
  100. #ifdef CHTYPE_LONG
  101.         if (color & A_STANDOUT)
  102.             if (enter_standout_mode != NULL)
  103.                 putp(enter_standout_mode);
  104.         if (color & A_ALTCHARSET)
  105.             {
  106.             if (last_acs == FALSE)
  107.                 if (enter_alt_charset_mode != NULL)
  108.                     putp(enter_alt_charset_mode);
  109.             last_acs = TRUE;
  110.             }
  111.         else
  112.             {
  113.             last_acs = FALSE;
  114.             if (exit_alt_charset_mode != NULL)
  115.                 putp(exit_alt_charset_mode);
  116.             }
  117. #endif
  118.         }
  119.     putchar(character & A_CHARTEXT);
  120.     return( OK );
  121. #endif
  122. }
  123.